package com.blackcat.recode.controller;


import com.blackcat.recode.common.annotation.Log;
import com.blackcat.recode.common.result.AjaxResult;
import com.blackcat.recode.entity.UpdateRecode;
import com.blackcat.recode.entity.Worker;
import com.blackcat.recode.enums.BusinessType;
import com.blackcat.recode.service.UpdateRecodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p> 更新记录表 前端控制器
 * @author blackcat 2024-09-10
 */
@RestController
@RequestMapping("/update")
public class UpdateRecodeController {

    @Autowired
    private UpdateRecodeService updateRecodeService;

    @GetMapping("/getList")
    public AjaxResult getList(Integer page, Integer size, String versionNo, String branchId, String serviceId, String projectId) {
        return updateRecodeService.getList(page, size, versionNo,branchId, serviceId, projectId);
    }

    @Log(title = "更新记录编辑", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody UpdateRecode updateRecode) {
        return updateRecodeService.edit(updateRecode);
    }

    @GetMapping("/getOne")
    public AjaxResult getOne(String id) {
        return AjaxResult.success(updateRecodeService.getById(id));
    }

    @Log(title = "更新记录删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/delete")
    public AjaxResult delete(String id) {
        return updateRecodeService.remove(id);
    }

    @GetMapping("/getVersionList")
    public AjaxResult getVersionList(String branchId,String serviceId,String projectId) {
        return updateRecodeService.getVersionList(branchId,serviceId,projectId);
    }
}
